package gat.common.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author sxq
 * @date 2021/12/22
 */

@AllArgsConstructor
@Getter
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum NoEnum {

    MSG_ID("","","msgId","%06d"),
    NO_PIR("", "", "无前缀", "%01d"),
    MSG_NAME("msg:name","M","msgName","%06d"),
    ESIGN_REQ("eSign:req","ER","e签宝请求ID","%03d"),
    COOPERATION_TEMPLATE("template:code","HZ","合作模板编码","%03d"),
    MESSAGE_TEMPLATE("","MSG_","消息模板编码","%03d"),
    USER_CODE("user:code","u_","用户编码","%06d"),
    ;

    private final String key;
    private final String prefix;
    private final String msg;
    private final String digit;

    /**
     * 根据code,获取描述信息
     *
     * @param key
     * @return
     */
    @JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
    public static NoEnum getByKey(@JsonProperty("key") String key) {
        for (NoEnum value : values()) {
            if (value.getKey().equals(key)) {
                return value;
            }
        }
        return null;
    }

}
